home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Communications / Networks / MailCheck 0.9x / drvr src / mmc_os_preserve.c < prev    next >
Text File  |  1992-06-15  |  915b  |  47 lines

  1. /*
  2.  * get/save resource manager state
  3.  */
  4.  
  5. #define OSP_protected_call xOSP_protected_call
  6. #include "mmc_os_preserve.h"
  7. #undef OSP_protected_call
  8.  
  9. long OSP_protected_call(int new_heap,
  10.     long (*cproc)(long a1,long a2,long a3,long a4),
  11.     long a1,
  12.     long a2,
  13.     long a3,
  14.     long a4);
  15.  
  16. long OSP_protected_call(new_heap,cproc,a1,a2,a3,a4)
  17. int new_heap;
  18. long (*cproc)(long a1,long a2,long a3,long a4);
  19. long a1,a2,a3,a4;
  20. {
  21.     THz oldZone;
  22.     long result;
  23.     ProcPtr old_res_err=ResErrProc;
  24.     int old_err_num=ResErr;
  25.     int old_load;
  26.     asm {
  27.         bra.s @skip_rts
  28.     new_err_proc:
  29.         rts
  30.     skip_rts:
  31.         lea @new_err_proc,a0
  32.         move.l a0,ResErrProc
  33.     }
  34.     oldZone = GetZone();
  35.     if((new_heap&OSP_sys)!=0)
  36.         SetZone(SystemZone());
  37.     old_load=ResLoad;
  38.     SetResLoad(((new_heap&OSP_noload)==0));
  39.     result=(*cproc)(a1,a2,a3,a4);
  40.     SetResLoad(old_load);
  41.     if((new_heap&OSP_sys)!=0)
  42.         SetZone(oldZone);
  43.     ResErrProc=old_res_err;
  44.     ResErr=old_err_num;
  45.     return result;
  46. }
  47.